package com.atlin.controller;

import com.atlin.model.params.LicenseParams;
import com.atlin.service.LicenseService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * license管理服务端
 */
@RestController
@RequestMapping("/license")
@RequiredArgsConstructor
public class LicenseController {

    private final LicenseService licenseService;

    /**
     * 证书生成
     *
     * @param file 客户端指纹信息数据文件
     */
    @PostMapping(value = "/generateLicense", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public void generateLicense(@RequestParam("file") MultipartFile file, @ModelAttribute LicenseParams licenseParams,
                                HttpServletResponse response) {
        licenseService.generateLicense(file, licenseParams, response);
    }
}
